COVID-19 ANALYSIS

In [49]:
import numpy as np
import pandas as pd
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
import plotly.graph_objs as go
import matplotlib.pyplot as plt
import cufflinks as cf
%matplotlib inline
import plotly.express as px
import folium
In [50]:
init_notebook_mode(connected=True)
In [51]:
cf.go_offline()

Importing Data

In [52]:
df = pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\Covid cases in India.xlsx')
In [53]:
df
Out[53]:
S. No. Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death
0 1 Andhra Pradesh 12 0 1 0
1 2 Chhattisgarh 6 0 0 0
2 3 Delhi 38 1 6 1
3 4 Gujarat 43 0 0 3
4 5 Haryana 16 14 11 0
5 6 Himachal Pradesh 4 0 0 1
6 7 Karnataka 20 0 3 2
7 8 Kerala 131 7 11 0
8 9 Madhya Pradesh 23 0 0 1
9 10 Maharashtra 144 3 15 4
10 11 Odisha 3 0 0 0
11 12 Puducherry 1 0 0 0
12 13 Punjab 29 0 0 1
13 14 Rajasthan 41 2 3 0
14 15 Tamil Nadu 32 3 1 1
15 16 Telengana 34 11 1 0
16 17 Chandigarh 7 0 0 0
17 18 Jammu and Kashmir 18 0 1 1
18 19 Ladakh 13 0 0 0
19 20 Uttar Pradesh 42 1 11 0
20 21 Uttarakhand 4 0 0 0
21 22 West Bengal 11 0 0 1
22 23 Bihar 7 0 0 1
23 24 Mizoram 1 0 0 0
24 25 Goa 6 0 0 0
25 26 Manipur 1 0 0 0
In [54]:
df.drop('S. No.',axis=1,inplace=True)
In [55]:
#craetw a new column named as total cases

df['total_cases'] = df['Total Confirmed cases (Indian National)']+df['Total Confirmed cases ( Foreign National )']
In [56]:
#to show the most cases we are using abck gradient

df.style.background_gradient(cmap='Reds')
Out[56]:
Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death total_cases
0 Andhra Pradesh 12 0 1 0 12
1 Chhattisgarh 6 0 0 0 6
2 Delhi 38 1 6 1 39
3 Gujarat 43 0 0 3 43
4 Haryana 16 14 11 0 30
5 Himachal Pradesh 4 0 0 1 4
6 Karnataka 20 0 3 2 20
7 Kerala 131 7 11 0 138
8 Madhya Pradesh 23 0 0 1 23
9 Maharashtra 144 3 15 4 147
10 Odisha 3 0 0 0 3
11 Puducherry 1 0 0 0 1
12 Punjab 29 0 0 1 29
13 Rajasthan 41 2 3 0 43
14 Tamil Nadu 32 3 1 1 35
15 Telengana 34 11 1 0 45
16 Chandigarh 7 0 0 0 7
17 Jammu and Kashmir 18 0 1 1 18
18 Ladakh 13 0 0 0 13
19 Uttar Pradesh 42 1 11 0 43
20 Uttarakhand 4 0 0 0 4
21 West Bengal 11 0 0 1 11
22 Bihar 7 0 0 1 7
23 Mizoram 1 0 0 0 1
24 Goa 6 0 0 0 6
25 Manipur 1 0 0 0 1
In [57]:
cases_in_each_state=df.groupby('Name of State / UT')['total_cases'].sum().sort_values(ascending=False).to_frame().reset_index()
In [58]:
#States of India and Total cases in each state
cases_in_each_state.style.background_gradient(cmap='PuBu')
Out[58]:
Name of State / UT total_cases
0 Maharashtra 147
1 Kerala 138
2 Telengana 45
3 Uttar Pradesh 43
4 Rajasthan 43
5 Gujarat 43
6 Delhi 39
7 Tamil Nadu 35
8 Haryana 30
9 Punjab 29
10 Madhya Pradesh 23
11 Karnataka 20
12 Jammu and Kashmir 18
13 Ladakh 13
14 Andhra Pradesh 12
15 West Bengal 11
16 Chandigarh 7
17 Bihar 7
18 Goa 6
19 Chhattisgarh 6
20 Uttarakhand 4
21 Himachal Pradesh 4
22 Odisha 3
23 Manipur 1
24 Mizoram 1
25 Puducherry 1

Data Visuvalization

In [59]:
#States of India vs Total cases

df.iplot(kind='bar',x='Name of State / UT',y='total_cases',color='red',title='States of India vs Total cases',xTitle='States of India',yTitle='Total cases')

df.iplot(kind='scatter',x='Name of State / UT',y='total_cases',color='red',mode='markers+lines',title='States of India vs Total cases',xTitle='States of India',yTitle='Total cases')
In [60]:
#correlation between each and every column

t = df.corr()
In [61]:
t
Out[61]:
Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death total_cases
Total Confirmed cases (Indian National) 1.000000 0.342938 0.776832 0.505713 0.995832
Total Confirmed cases ( Foreign National ) 0.342938 1.000000 0.528416 -0.125513 0.427184
Cured 0.776832 0.528416 1.000000 0.285954 0.799034
Death 0.505713 -0.125513 0.285954 1.000000 0.474580
total_cases 0.995832 0.427184 0.799034 0.474580 1.000000
In [62]:
import seaborn as sns # another data visuvalization tool
In [63]:
plt.figure(figsize=(10,8)) #using matplotlib library
sns.heatmap(df.corr(),annot=True)
Out[63]:
<matplotlib.axes._subplots.AxesSubplot at 0x1c6454c1048>
In [64]:
#coordinates of each state in india
#dataset contains all states latitude and longitude

india_coordinates = pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\Indian Coordinates.xlsx')
In [65]:
india_coordinates
Out[65]:
Name of State / UT Latitude Longitude
0 Andaman And Nicobar 11.667026 92.735983
1 Andhra Pradesh 14.750429 78.570026
2 Arunachal Pradesh 27.100399 93.616601
3 Assam 26.749981 94.216667
4 Bihar 25.785414 87.479973
5 Chandigarh 30.719997 76.780006
6 Chhattisgarh 22.090420 82.159987
7 Dadra And Nagar Haveli 20.266578 73.016618
8 Delhi 28.669993 77.230004
9 Goa 15.491997 73.818001
10 Haryana 28.450006 77.019991
11 Himachal Pradesh 31.100025 77.166597
12 Union Territory of Jammu and Kashmir 33.450000 76.240000
13 Jharkhand 23.800393 86.419986
14 Karnataka 12.570381 76.919997
15 Kerala 8.900373 76.569993
16 Lakshadweep 10.562573 72.636867
17 Madhya Pradesh 21.300391 76.130019
18 Maharashtra 19.250232 73.160175
19 Manipur 24.799971 93.950017
20 Meghalaya 25.570492 91.880014
21 Mizoram 23.710399 92.720015
22 Nagaland 25.666998 94.116570
23 Orissa 19.820430 85.900017
24 Puducherry 11.934994 79.830000
25 Punjab 31.519974 75.980003
26 Rajasthan 26.449999 74.639981
27 Sikkim 27.333330 88.616647
28 Telengana 18.112400 79.019300
29 Tamil Nadu 12.920386 79.150042
30 Tripura 23.835404 91.279999
31 Uttar Pradesh 27.599981 78.050006
32 Uttarakhand 30.320409 78.050006
33 West Bengal 22.580390 88.329947
34 Union Territory of Ladakh 34.100000 77.340000
In [66]:
#Here we are merging the dataframes of orginal dataframe and coordinates dataframe

df_new = pd.merge(india_coordinates,df,on='Name of State / UT')
In [67]:
df_new
Out[67]:
Name of State / UT Latitude Longitude Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death total_cases
0 Andhra Pradesh 14.750429 78.570026 12 0 1 0 12
1 Delhi 28.669993 77.230004 38 1 6 1 39
2 Haryana 28.450006 77.019991 16 14 11 0 30
3 Karnataka 12.570381 76.919997 20 0 3 2 20
4 Kerala 8.900373 76.569993 131 7 11 0 138
5 Maharashtra 19.250232 73.160175 144 3 15 4 147
6 Punjab 31.519974 75.980003 29 0 0 1 29
7 Rajasthan 26.449999 74.639981 41 2 3 0 43
8 Telengana 18.112400 79.019300 34 11 1 0 45
9 Tamil Nadu 12.920386 79.150042 32 3 1 1 35
10 Uttar Pradesh 27.599981 78.050006 42 1 11 0 43
11 Uttarakhand 30.320409 78.050006 4 0 0 0 4
In [68]:
#for geo locations

import folium
In [69]:
locations_of_india = df_new[['Latitude','Longitude']]
In [70]:
locationlist_of_india = locations_of_india.values.tolist()
len(locationlist_of_india)
Out[70]:
12
In [71]:
map = folium.Map(location=[20, 70], zoom_start=5)
for points in range(0, len(locationlist_of_india)):
    folium.Marker(locationlist_of_india[points], popup=df_new['Name of State / UT'][points]).add_to(map)
In [72]:
map
Out[72]:
In [ ]:
 
In [73]:
#how the COVID-19 raising globally by data viz(taken only four countries)
In [74]:
india_cases=pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\per_day_cases.xlsx',parse_dates=True,sheet_name='India')
italy_cases=pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\per_day_cases.xlsx',parse_dates=True,sheet_name='Italy')
SKorea_cases=pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\per_day_cases.xlsx',parse_dates=True,sheet_name='Korea')
china_cases=pd.read_excel(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\per_day_cases.xlsx',parse_dates=True,sheet_name='Wuhan')
In [75]:
india_cases
Out[75]:
Date Total Cases New Cases Days after surpassing 100 cases
0 2020-01-30 1 1 NaN
1 2020-01-31 1 0 NaN
2 2020-02-01 1 0 NaN
3 2020-02-02 2 1 NaN
4 2020-02-03 3 1 NaN
5 2020-02-04 3 0 NaN
6 2020-02-05 3 0 NaN
7 2020-02-06 3 0 NaN
8 2020-02-07 3 0 NaN
9 2020-02-08 3 0 NaN
10 2020-02-09 3 0 NaN
11 2020-02-10 3 0 NaN
12 2020-02-11 3 0 NaN
13 2020-02-12 3 0 NaN
14 2020-02-13 3 0 NaN
15 2020-02-14 3 0 NaN
16 2020-02-15 3 0 NaN
17 2020-02-16 3 0 NaN
18 2020-02-17 3 0 NaN
19 2020-02-18 3 0 NaN
20 2020-02-19 3 0 NaN
21 2020-02-20 3 0 NaN
22 2020-02-21 3 0 NaN
23 2020-02-22 3 0 NaN
24 2020-02-23 3 0 NaN
25 2020-02-24 3 0 NaN
26 2020-02-25 3 0 NaN
27 2020-02-26 3 0 NaN
28 2020-02-27 3 0 NaN
29 2020-02-28 3 0 NaN
30 2020-02-29 3 0 NaN
31 2020-03-01 3 0 NaN
32 2020-03-02 6 3 NaN
33 2020-03-03 9 3 NaN
34 2020-03-04 28 19 NaN
35 2020-03-05 30 2 NaN
36 2020-03-06 31 1 NaN
37 2020-03-07 34 3 NaN
38 2020-03-08 39 5 NaN
39 2020-03-09 43 4 NaN
40 2020-03-10 56 13 NaN
41 2020-03-11 62 6 NaN
42 2020-03-12 73 11 NaN
43 2020-03-13 82 9 NaN
44 2020-03-14 102 20 0.0
45 2020-03-15 113 11 1.0
46 2020-03-16 119 6 2.0
47 2020-03-17 142 23 3.0
48 2020-03-18 156 14 4.0
49 2020-03-19 194 38 5.0
50 2020-03-20 244 50 6.0
51 2020-03-21 271 27 7.0
In [76]:
#data viz
In [77]:
fig = px.bar(data_frame=india_cases,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in india')
fig.show()
india_cases.iplot(kind='scatter',x='Date',y='Total Cases',mode='markers+lines',color='#FF6847')
In [78]:
fig = px.bar(data_frame=italy_cases,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in italy')
fig.show()
italy_cases.iplot(kind='scatter',x='Date',y='Total Cases',mode='markers+lines',color='#FF6847')
In [79]:
fig = px.bar(data_frame=SKorea_cases,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in southkorea')
fig.show()
SKorea_cases.iplot(kind='scatter',x='Date',y='Total Cases',mode='markers+lines',color='#FF6847')
In [80]:
fig = px.bar(data_frame=china_cases,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in wuhan')
fig.show()
china_cases.iplot(kind='scatter',x='Date',y='Total Cases',mode='markers+lines',color='#FF6847')
In [81]:
#Box plot of the original dataframe to know from where to where the cases vary
In [82]:
df.iplot(kind='box')
In [83]:
# COVI19 world data collected(from that data)
In [84]:
df=pd.read_csv(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\covid_19_data.csv',parse_dates=['Last Update'])
In [85]:
df
df.rename(columns={'Country/Region':'Country','Province/State':'State'},inplace=True)
In [86]:
df.query('Country=="India"')
Out[86]:
SNo ObservationDate State Country Last Update Confirmed Deaths Recovered
430 431 01/30/2020 NaN India 2020-01-30 16:00:00 1.0 0.0 0.0
491 492 01/31/2020 NaN India 2020-01-31 23:59:00 1.0 0.0 0.0
547 548 02/01/2020 NaN India 2020-01-31 08:15:00 1.0 0.0 0.0
607 608 02/02/2020 NaN India 2020-02-02 06:03:08 2.0 0.0 0.0
672 673 02/03/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
740 741 02/04/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
810 811 02/05/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
881 882 02/06/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
954 955 02/07/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1026 1027 02/08/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1098 1099 02/09/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1171 1172 02/10/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1243 1244 02/11/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1316 1317 02/12/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1389 1390 02/13/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1463 1464 02/14/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1538 1539 02/15/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1613 1614 02/16/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1688 1689 02/17/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1763 1764 02/18/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1838 1839 02/19/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1915 1916 02/20/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1995 1996 02/21/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2079 2080 02/22/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2163 2164 02/23/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2248 2249 02/24/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2341 2342 02/25/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2438 2439 02/26/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2543 2544 02/27/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2650 2651 02/28/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2771 2772 02/29/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2895 2896 03/01/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
3016 3017 03/02/2020 NaN India 2020-03-02 22:33:09 5.0 0.0 3.0
3162 3163 03/03/2020 NaN India 2020-03-02 22:33:09 5.0 0.0 3.0
3288 3289 03/04/2020 NaN India 2020-03-04 12:33:03 28.0 0.0 3.0
3451 3452 03/05/2020 NaN India 2020-03-05 13:53:03 30.0 0.0 3.0
3624 3625 03/06/2020 NaN India 2020-03-06 13:03:12 31.0 0.0 3.0
3825 3826 03/07/2020 NaN India 2020-03-07 18:13:27 34.0 0.0 3.0
4051 4052 03/08/2020 NaN India 2020-03-08 09:23:05 39.0 0.0 3.0
4308 4309 03/09/2020 NaN India 2020-03-09 09:13:17 43.0 0.0 3.0
4573 4574 03/10/2020 NaN India 2020-03-10 10:13:28 56.0 0.0 4.0
4781 4782 03/11/2020 NaN India 2020-03-11 22:13:12 62.0 1.0 4.0
4996 4997 03/12/2020 NaN India 2020-03-12 08:33:13 73.0 1.0 4.0
5277 5278 03/13/2020 NaN India 2020-03-11 20:00:00 82.0 2.0 4.0
5451 5452 03/14/2020 NaN India 2020-03-14 20:33:03 102.0 2.0 4.0
5699 5700 03/15/2020 NaN India 2020-03-15 18:20:18 113.0 2.0 13.0
In [87]:
df.groupby('ObservationDate').sum()
Out[87]:
SNo Confirmed Deaths Recovered
ObservationDate
01/22/2020 741 555.0 17.0 28.0
01/23/2020 2829 653.0 18.0 30.0
01/24/2020 4305 941.0 26.0 36.0
01/25/2020 6490 1438.0 42.0 39.0
01/26/2020 9071 2118.0 56.0 52.0
01/27/2020 12342 2927.0 82.0 61.0
01/28/2020 15262 5578.0 131.0 107.0
01/29/2020 18711 6165.0 133.0 126.0
01/30/2020 23345 8235.0 171.0 143.0
01/31/2020 28675 9925.0 213.0 222.0
02/01/2020 35309 12038.0 259.0 284.0
02/02/2020 39798 16787.0 362.0 472.0
02/03/2020 44982 19881.0 426.0 623.0
02/04/2020 51135 23892.0 492.0 852.0
02/05/2020 56871 27636.0 564.0 1124.0
02/06/2020 61912 30818.0 634.0 1487.0
02/07/2020 67932 34392.0 719.0 2011.0
02/08/2020 73116 37121.0 806.0 2616.0
02/09/2020 78300 40151.0 906.0 3244.0
02/10/2020 83484 42763.0 1013.0 3946.0
02/11/2020 89936 44803.0 1113.0 4683.0
02/12/2020 95265 45222.0 1118.0 5150.0
02/13/2020 102009 60370.0 1371.0 6295.0
02/14/2020 108975 66887.0 1523.0 8058.0
02/15/2020 114600 69032.0 1666.0 9395.0
02/16/2020 120225 71226.0 1770.0 10865.0
02/17/2020 125850 73260.0 1868.0 12583.0
02/18/2020 131475 75138.0 2007.0 14352.0
02/19/2020 138966 75641.0 2122.0 16121.0
02/20/2020 144742 76199.0 2247.0 18177.0
02/21/2020 166698 76843.0 2251.0 18890.0
02/22/2020 173754 78599.0 2458.0 22886.0
02/23/2020 183005 78985.0 2469.0 23394.0
02/24/2020 201645 79570.0 2629.0 25227.0
02/25/2020 219255 80415.0 2708.0 27905.0
02/26/2020 245430 81397.0 2770.0 30384.0
02/27/2020 265965 82756.0 2814.0 33277.0
02/28/2020 301245 84124.0 2872.0 36711.0
02/29/2020 328321 86013.0 2941.0 39782.0
03/01/2020 360125 88371.0 2996.0 42716.0
03/02/2020 424974 90309.0 3085.0 45602.0
03/03/2020 477160 92844.0 3160.0 48229.0
03/04/2020 530480 95124.0 3254.0 51171.0
03/05/2020 602386 97886.0 3348.0 53797.0
03/06/2020 729932 101800.0 3460.0 55866.0
03/07/2020 873000 105836.0 3558.0 58359.0
03/08/2020 1050600 109835.0 3803.0 60695.0
03/09/2020 1165213 113582.0 3996.0 62512.0
03/10/2020 950999 118582.0 4262.0 64404.0
03/11/2020 1042740 125865.0 4615.0 67003.0
03/12/2020 1099701 128343.0 4720.0 68324.0
03/13/2020 1211755 145193.0 5404.0 70251.0
03/14/2020 1371492 156099.0 5819.0 72624.0
03/15/2020 1486467 167447.0 6440.0 76034.0
In [88]:
confirmed = df.groupby('ObservationDate').sum()['Confirmed'].reset_index()
deaths = df.groupby('ObservationDate').sum()['Deaths'].reset_index()
recoverd = df.groupby('ObservationDate').sum()['Recovered'].reset_index()
deaths
Out[88]:
ObservationDate Deaths
0 01/22/2020 17.0
1 01/23/2020 18.0
2 01/24/2020 26.0
3 01/25/2020 42.0
4 01/26/2020 56.0
5 01/27/2020 82.0
6 01/28/2020 131.0
7 01/29/2020 133.0
8 01/30/2020 171.0
9 01/31/2020 213.0
10 02/01/2020 259.0
11 02/02/2020 362.0
12 02/03/2020 426.0
13 02/04/2020 492.0
14 02/05/2020 564.0
15 02/06/2020 634.0
16 02/07/2020 719.0
17 02/08/2020 806.0
18 02/09/2020 906.0
19 02/10/2020 1013.0
20 02/11/2020 1113.0
21 02/12/2020 1118.0
22 02/13/2020 1371.0
23 02/14/2020 1523.0
24 02/15/2020 1666.0
25 02/16/2020 1770.0
26 02/17/2020 1868.0
27 02/18/2020 2007.0
28 02/19/2020 2122.0
29 02/20/2020 2247.0
30 02/21/2020 2251.0
31 02/22/2020 2458.0
32 02/23/2020 2469.0
33 02/24/2020 2629.0
34 02/25/2020 2708.0
35 02/26/2020 2770.0
36 02/27/2020 2814.0
37 02/28/2020 2872.0
38 02/29/2020 2941.0
39 03/01/2020 2996.0
40 03/02/2020 3085.0
41 03/03/2020 3160.0
42 03/04/2020 3254.0
43 03/05/2020 3348.0
44 03/06/2020 3460.0
45 03/07/2020 3558.0
46 03/08/2020 3803.0
47 03/09/2020 3996.0
48 03/10/2020 4262.0
49 03/11/2020 4615.0
50 03/12/2020 4720.0
51 03/13/2020 5404.0
52 03/14/2020 5819.0
53 03/15/2020 6440.0
In [89]:
 #data viz
    
In [90]:
fig = go.Figure()
fig.add_trace(go.Scatter(x=confirmed['ObservationDate'],y=confirmed['Confirmed'],mode='lines+markers',name='Confirmed',line=dict(color='green',width=2)))
fig.add_trace(go.Scatter(x=deaths['ObservationDate'],y=deaths['Deaths'],mode='lines+markers',name='Deaths',line=dict(color='red',width=2)))
fig.add_trace(go.Scatter(x=recoverd['ObservationDate'],y=recoverd['Recovered'],mode='lines+markers',name='Recovered',line=dict(color='blue',width=2)))
In [91]:
df_confirmed=pd.read_csv(r'C:\Users\HP\Desktop\COVID-19-Time-Series-Forecasting-with-Data-Analysis-master\time_series_covid_19_confirmed.csv')
In [92]:
df_confirmed
Out[92]:
Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 ... 3/5/20 3/6/20 3/7/20 3/8/20 3/9/20 3/10/20 3/11/20 3/12/20 3/13/20 3/14/20
0 NaN Thailand 15.0000 101.0000 2 3 5 7 8 8 ... 47 48 50 50 50 53 59 70 75 82
1 NaN Japan 36.0000 138.0000 2 1 2 2 4 4 ... 360 420 461 502 511 581 639 639 701 773
2 NaN Singapore 1.2833 103.8333 0 1 3 3 4 5 ... 117 130 138 150 150 160 178 178 200 212
3 NaN Nepal 28.1667 84.2500 0 0 0 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
4 NaN Malaysia 2.5000 112.5000 0 0 0 3 4 4 ... 50 83 93 99 117 129 149 149 197 238
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
437 NaN Saint Lucia 13.9094 -60.9789 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 1
438 NaN Saint Vincent and the Grenadines 12.9843 -61.2872 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 1
439 NaN Suriname 3.9193 -56.0278 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 1
440 Virgin Islands, U.S. US 18.3358 -64.8963 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 1
441 NaN occupied Palestinian territory 31.9522 35.2332 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0

442 rows × 57 columns

In [93]:
df_confirmed.rename(columns={'Country/Region':'Country'},inplace=True)
In [94]:
df_latlong_world=pd.merge(df,df_confirmed,on=['Country'])
In [95]:
df_latlong_world
Out[95]:
SNo ObservationDate State Country Last Update Confirmed Deaths Recovered Province/State Lat ... 3/5/20 3/6/20 3/7/20 3/8/20 3/9/20 3/10/20 3/11/20 3/12/20 3/13/20 3/14/20
0 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 Washington 47.4009 ... 0 0 0 0 0 267 366 442 568 572
1 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 New York 42.1657 ... 0 0 0 0 0 173 220 328 421 525
2 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 California 36.1162 ... 0 0 0 0 0 144 177 221 282 340
3 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 Massachusetts 42.2302 ... 0 0 0 0 0 92 95 108 123 138
4 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 Diamond Princess 35.4437 ... 45 45 45 45 45 46 46 46 46 46
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
305852 5878 03/15/2020 NaN Saint Lucia 2020-03-14 16:15:18 2.0 0.0 0.0 NaN 13.9094 ... 0 0 0 0 0 0 0 0 0 1
305853 5623 03/14/2020 NaN Saint Vincent and the Grenadines 2020-03-14 16:33:03 1.0 0.0 0.0 NaN 12.9843 ... 0 0 0 0 0 0 0 0 0 1
305854 5879 03/15/2020 NaN Saint Vincent and the Grenadines 2020-03-14 16:33:03 1.0 0.0 0.0 NaN 12.9843 ... 0 0 0 0 0 0 0 0 0 1
305855 5625 03/14/2020 NaN Suriname 2020-03-14 16:33:03 1.0 0.0 0.0 NaN 3.9193 ... 0 0 0 0 0 0 0 0 0 1
305856 5881 03/15/2020 NaN Suriname 2020-03-14 16:33:03 1.0 0.0 0.0 NaN 3.9193 ... 0 0 0 0 0 0 0 0 0 1

305857 rows × 64 columns

In [96]:
fig=px.density_mapbox(df_latlong_world,lat='Lat',lon='Long',hover_name='Province/State',hover_data=['Confirmed','Deaths','Recovered'],animation_frame='ObservationDate',color_continuous_scale='portland',zoom=0,radius=7,height=700)
fig.update_layout(title='World wide corana virus')
fig.update_layout(mapbox_style='open-street-map',mapbox_center_lon=0)
fig.update_layout(margin={'r':0,'t':0,'l':0,'b':0})

NOTE:The above world map shows the covid19 cases incresases day by day in each every country

use play button to view the pandemic effect on the world

Thank You...!